<template>
  <div class="home">
    <div class="banner">
      <h1>Katana</h1>
      <p>自由分享的社区</p>
    </div>
    <div class="container" v-if="articles && articles.length !== 0">
      <article-list
        :articles="articles" 
      />
      <app-pagination
        :count="articlesCount"
        :curIdx="page"
        @changePage="changePage"
      />
    </div>
  </div>
</template>

<script lang="ts">
  import { defineComponent } from 'vue'
  import ArticleList from 'src/components/ArticleList/index.vue'
  import AppPagination from 'src/components/common/AppPagination/index.vue'
  import useArticles from 'src/hooks/useArticles'
  export default defineComponent({
    components: {
      ArticleList,
      AppPagination
    },
    setup () {
      const {
        articles,
        articlesCount,
        page,
        changePage,
        fetchArticles
      } = useArticles('home')

      fetchArticles()

      return {
        articles,
        articlesCount,
        page,
        changePage
      }
    }
  })
</script>

<style lang="scss" scoped>
  @import "src/assets/scss/variables.scss";
  .banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 250px;
    background-color: $backgroundColor;
    color: white;
    box-shadow: 0 0 4px rgba($color: #000000, $alpha: 0.6) inset;
    h1 {
      font-size: 72px;
    }
    p {
      font-size: 36px;
      margin-top: 24px;
    }
  }
</style>